package com.zy.explore.sys.interfaces.facade.v1;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zy.explore.common.interfaces.vo.ResultVO;
import com.zy.explore.sys.application.service.DingTalkService;
import com.zy.explore.sys.infrastructure.third.dingtalk.vo.DingDeptVO;
import com.zy.explore.sys.infrastructure.third.dingtalk.vo.DingUserVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * description 钉钉交互控制器
 *
 * @author ChinaYin  主页:https://gitee.com/zy-explorej2ee 邮箱:zyexplorej2ee@sina.com
 * @date 2021年04月03日 20:40
 **/
@Api(tags = "钉钉组织机构管理")
@Slf4j
@RestController
@RequestMapping("/dingTalk")
public class DingTalkFacade {

    @Resource
    private DingTalkService dingTalkService;

    @ApiOperationSupport(order = 10)
    @ApiOperation("获取钉钉的所有部门列表")
    @GetMapping("/getDingDeptList")
    public ResultVO<List<DingDeptVO>> getDingDeptList() {
        return ResultVO.getSuccess(dingTalkService.getDingDeptList());
    }

    @ApiOperationSupport(order = 20)
    @ApiOperation("获取钉钉的所有员工列表")
    @GetMapping("/getDingUserList")
    public ResultVO<List<DingUserVO>> getDingUserList() {
        return ResultVO.getSuccess(dingTalkService.getDingUserList(1L, true));
    }

    @ApiOperationSupport(order = 30)
    @ApiOperation("同步钉钉部门和员工")
    @GetMapping("/asyncDingTalkDeptAndEmployee")
    public ResultVO<Boolean> asyncDingTalkDeptAndEmployee() {
        return ResultVO.getSuccess(dingTalkService.syncDingTalkDeptAndEmployee());
    }

    @ApiOperationSupport(order = 40)
    @ApiOperation("查询当前钉钉同步状态")
    @GetMapping("/getSyncStatus")
    public ResultVO<Boolean> getSyncStatus() {
        return ResultVO.getSuccess(dingTalkService.getSyncStatus());
    }

}
